import request from '@/utils/request'

/**
 * 将创建的聊天会话保存的服务端
 * @param data 聊天会话
 * @returns {AxiosPromise}
 */
export function createConversation(data) {
  return request({
    url:'/conversation/create',
    method:'post',
    data
  })
}

/**
 * 请求会话列表
 * @returns {AxiosPromise}
 */
export function getConversationList(){
  return request({
    url:'/conversation/list',
    method:'get',
  })
}


/**
 * 修改指定会话的展示状态
 * @param userid 账号
 * @returns {AxiosPromise}
 */
export function showConversation(userid) {
  return request({
    url:'/conversation/show',
    method:'get',
    params:{userid}
  })
}

/**
 * 将指定会话消息发送到服务器
 * @param message
 * @returns {AxiosPromise}
 */
export function sendConversationMessage(message) {
  return request({
    url:'/conversationMessage/save',
    method:'post',
    data:message
  })
}

/**
 * 指定页码获取会话列表中的消息
 * @param conversationId 会话id
 * @param page 消息页码
 * @returns {AxiosPromise}
 */
export function getConversationListMessage(conversationId,page) {
  return request({
    url:'/conversationMessage/getMessage',
    method:'get',
    params:{conversationId,page}
  })
}

/**
 * 修改会话消息状态
 * @param conversationId 会话id
 * @param status 状态
 * @returns {AxiosPromise}
 */
export function modifyMessageStatus(conversationId,status) {
  return request({
    url:'/conversationMessage/modifyStatus',
    method:'get',
    params:{conversationId,status}
  })
}
